home *** CD-ROM | disk | FTP | other *** search
- Path: qualcomm.com!usenet
- From: nabbasi@qualcomm.com (Nasser Abbasi)
- Newsgroups: comp.lang.c++
- Subject: Re: VMS Descriptors in C++?
- Date: 8 Feb 1996 00:01:48 GMT
- Organization: QUALCOMM
- Message-ID: <4fbehc$sdl@qualcomm.com>
- References: <1996Feb7.143723.25305@alw.nih.gov>
- NNTP-Posting-Host: nabbasi.qualcomm.com
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <1996Feb7.143723.25305@alw.nih.gov>,
- systex@BALROG.NCI.NIH.GOV210-7701 says...
-
- >/*
- > * A simple macro to construct a string descriptor:
- > */
- >#define $DESCRIPTOR(name,string) struct dsc$descriptor_s name = {
- sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
- >
- >An example of a call to the macro would be:
- >
- >
- > dsc$descriptor_s dsc;
- > $DESCRIPTOR(dsc, "XYZ");
- > status = SYS$GETDVI (0, 0, &dsc, &itmlst[0], &iosb, 0, 0, 0);
- >
- >The $DESCRIPTOR syntax only takes literal character array and not a
- Class
- >strings. If I create a subroutine to call the system service by passing
- a
- >literal character array, that works fine. However, if I pass a string
- object,
- >then the $DESCRIPTOR fails.
- >
-
- Hello,
-
- You need to have a second look at the dsc$descriptor macro.
-
- It seems to me that "XYZ" is the what is passed to macro with the
- name "string" , and then you doing sizeof(string)-1 , which will expand
- to sizeof("XYZ") -1 . That should be strlen(string) -1.
-
- If I remember there are different descriptors for different types of
- strings. you might want to use the descriptor that uses the strlen(), not
- sizeof().
-
- And the dsc$descriptor do not ONLY take literal characters, it can take
- pointer to buffer, you just need to make sure you use the correct macro.
- (the last parameter in the macro is the address of the buffer)
-
- Also look at the type of buffer you are using. there are macros
- for static buffers, there are ones for dynamic (heap) buffers, That is
- what the second parameter in the macro is for . for example DSC$K_DTYPE_T
- means Dynamic buffer. You need to know what each one of these parameter
- in the macro means. forgot what the third parameter for right now. (the
- class parameter).
-
- It has been years since I have used this macro, and this is from
- memeory, but the bottom line is that if you pass the macro the arguments
- it wants correclty then things will work fine. If you do not, then it
- will not work.
-
- Nasser
-
-
-
-